#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
 struct ps {
	int k;
	int a[10];
	struct ps*next;
}; typedef struct ps pd;
int main()
{
	int N;
	cin >> N;
	pd* head, *tail, *p;
	p = (struct ps*)malloc(sizeof(struct ps));
	head = p;
	tail = p;
	head->next = 0[]
	int i = 0;
	int arr[1000] = { 0 };
	int  maxn = 0;
	for (i = 0; i < N; i++)
	{
		p = (struct ps*)malloc(sizeof(struct ps));
		cin >> p->k;
		for (int j = 0; j < p->k; j++)
		{
			cin >> p->a[j];
			arr[p->a[j]]++;
		}
		tail->next = p;
		tail = p;
		tail->next = NULL;
	}
	int s = 0;
	for(i=999;i>0;i--)
		if (arr[i] > maxn)
		{
			maxn = arr[i];
			s = i;
		}
	cout << s << " " << maxn;
	return 0;
}
